<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form :inline="true" ref="listQuery" :model="listQuery" class="demo-form-inline">
        <el-form-item prop="code" label="项目编号">
          <el-input v-model="listQuery.code" placeholder="项目编号" @keyup.enter="handleFilter" />
        </el-form-item>
        <el-form-item prop="name" label="项目名称">
          <el-input v-model="listQuery.name" placeholder="项目名称" @keyup.enter="handleFilter" />
        </el-form-item>
        <el-form-item prop="workUserId" label="项目负责人">
          <User v-model="listQuery.workUserId" keyName="id" keyShow="name" placeholder="项目负责人" title="项目负责人查询" />
        </el-form-item>
        <el-form-item prop="startTime" label="年份年度">
          <el-input v-model="listQuery.startTime" placeholder="年份年度" @keyup.enter="handleFilter" />
        </el-form-item>
        <el-form-item prop="viability" label="存续状态">
          <el-select v-model="listQuery.viability" class="m-2" placeholder="请选择">
            <el-option key="" label="全部" value="" />
            <el-option v-for="item in getDictList('BudgetProjectViability')" :key="item.key" :label="`${item.key} - ${item.value}`" :value="item.key" />
          </el-select>
        </el-form-item>
        <el-form-item prop="ysySync" label="预算域同步状态">
          <el-select v-model="listQuery.ysySync" class="m-2" placeholder="请选择">
            <el-option key="" label="全部" value="" />
            <el-option v-for="item in getEnumList('BudgetProjectTwoSync')" :key="item.key" :label="item.value" :value="item.key" />
          </el-select>
        </el-form-item>
        <el-form-item prop="state" label="状态">
          <el-select v-model="listQuery.state" class="m-2" placeholder="请选择">
            <el-option key="" label="全部" value="" />
            <el-option v-for="item in getEnumList('BudgetProjectTwoState')" :key="item.key" :label="item.value" :value="item.key" />
          </el-select>
        </el-form-item>
        <el-form-item prop="libraryState" label="项目库状态">
          <el-select v-model="listQuery.libraryState" class="m-2" placeholder="请选择" disabled>
            <el-option key="" label="全部" value="" />
            <el-option v-for="item in getEnumList('BudgetProjectTwoLibraryState')" :key="item.key" :label="item.value" :value="item.key" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button v-waves type="success" icon="Search" @click="handleFilter">
            查询
          </el-button>
          <el-button icon="Refresh" @click="handleResetQuery">
            重置
          </el-button>
          <el-button v-show="checkAuthByCode('')" type="primary" icon="Download" @click="handleExport">
            导出
          </el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-divider class="el-divider--horizontal-margin" />
    <el-table v-loading="listLoading"
              :key="tableKey"
              :data="list"
              :row-style="{height: '0'}"
              :cell-style="{padding: '0'}"
              border
              fit
              highlight-current-row
              tooltip-effect="dark"
              @sort-change="handleSortChange"
              @selection-change="handleSelectionChange">
      <el-table-column align="center" type="index" label="序号" width="60px" />
      <el-table-column v-if="isDebug" align="center" label="ID" prop="id" width="60px" sortable show-overflow-tooltip />
      <el-table-column align="center" label="项目编号" prop="code" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.code }}</template>
      </el-table-column>
      <el-table-column align="center" label="项目名称" prop="name" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.name }}</template>
      </el-table-column>
      <el-table-column align="center" label="存续状态" prop="viability" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <DictTag :dict-list="getDictList('BudgetProjectViability')" :dict-key="row.viability" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="项目来源" prop="source" min-width="180px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <DictTag :dict-list="getDictList('BudgetProjectSource')" :dict-key="row.source" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="项目属性" prop="attribute" min-width="120px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <DictTag :dict-list="getDictList('BudgetProjectAttribute')" :dict-key="row.attribute" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="状态" prop="state" min-width="160px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <EnumTag :enum-list="getEnumList('BudgetProjectTwoState')" :enum-key="row.state" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="申请财政总额" prop="totalFund" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.totalFund }}</template>
      </el-table-column>
      <el-table-column align="center" label="社会投入资金" prop="putinFund" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.putinFund }}</template>
      </el-table-column>
      <el-table-column align="center" label="当年资金" prop="currFund" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.currFund }}</template>
      </el-table-column>
      <el-table-column align="center" label="用款单位" prop="useGovId" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}"><LabelTag :foreignList="governmentList" :foreignIds="row.workGovId" :foreignLabel="'governmentName'" /></template>
      </el-table-column>
      <el-table-column align="center" label="申报单位" prop="applyGovId" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}"><LabelTag :foreignList="governmentList" :foreignIds="row.applyGovId" :foreignLabel="'governmentName'" /></template>
      </el-table-column>
      <el-table-column align="center" label="上一年项目预算安排情况" prop="previousArrange" min-width="280px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.previousArrange }}</template>
      </el-table-column>
      <el-table-column align="center" label="主管部门" prop="managerOrgId" min-width="205px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ getIdLabel(budgetCompetentList, row.managerOrgId, "name") }}</template>
      </el-table-column>
      <el-table-column align="center" label="主管部门联系人" prop="managerName" min-width="205px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ getIdLabel(budgetCompetentList, row.managerOrgId, "contact") }}</template>
      </el-table-column>
      <el-table-column align="center" label="主管部门联系电话" prop="managerUserContact" min-width="205px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ getIdLabel(budgetCompetentList, row.managerOrgId, "telephone") }}</template>
      </el-table-column>
      <el-table-column align="center" label="项目实施单位" prop="workGovId" min-width="205px" sortable show-overflow-tooltip>
        <template v-slot="{row}"><LabelTag :foreignList="governmentList" :foreignIds="row.workGovId" :foreignLabel="'governmentName'" /></template>
      </el-table-column>
      <el-table-column align="center" label="项目负责人" prop="workUserId" min-width="130px" sortable show-overflow-tooltip>
        <template v-slot="{row}"><LabelTag :foreignList="userList" :foreignIds="row.workUserId" :foreignLabel="'name'" /></template>
      </el-table-column>
      <el-table-column align="center" label="项目负责人联系方式" prop="workUserContact" min-width="230px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.workUserContact }}</template>
      </el-table-column>
      <el-table-column align="center" label="起始年度" prop="startTime" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.startTime }}</template>
      </el-table-column>
      <el-table-column align="center" label="终止年度" prop="endTime" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.endTime }}</template>
      </el-table-column>
      <el-table-column align="center" label="项目概述" prop="summarize" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.summarize }}</template>
      </el-table-column>
      <el-table-column align="center" label="设立依据及申报理由" prop="reason" min-width="230px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.reason }}</template>
      </el-table-column>
      <el-table-column align="center" label="是否债券可用项目" prop="isDebenture" min-width="205px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <EnumTag :enum-list="getEnumList('CommonYesNo')" :enum-key="row.isDebenture" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="是否科研项目" prop="isScientific" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <EnumTag :enum-list="getEnumList('CommonYesNo')" :enum-key="row.isScientific" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="是否基建项目" prop="isConstruction" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <EnumTag :enum-list="getEnumList('CommonYesNo')" :enum-key="row.isConstruction" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="基建立项情况" prop="constructionDesc" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <DictTag :dict-list="getDictList('BudgetProjectConstruction')" :dict-key="row.constructionDesc" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="是否代建项目" prop="isAgent" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <EnumTag :enum-list="getEnumList('CommonYesNo')" :enum-key="row.isAgent" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="代建单位" prop="agentGovId" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}"><LabelTag :foreignList="governmentList" :foreignIds="row.agentGovId" :foreignLabel="'governmentName'" /></template>
      </el-table-column>
      <!--
      <el-table-column align="center" label="是否政府采购" prop="isGovernmentPurchase" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.isGovernmentPurchase }}</template>
      </el-table-column>
      <el-table-column align="center" label="采购项目" prop="purchaseProject" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.purchaseProject }}</template>
      </el-table-column>
      <el-table-column align="center" label="采购品目" prop="purchaseKind" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.purchaseKind }}</template>
      </el-table-column>
      <el-table-column align="center" label="采购需求概况" prop="purchaseRequire" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.purchaseRequire }}</template>
      </el-table-column>
      <el-table-column align="center" label="预计采购时间" prop="purchaseDate" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.purchaseDate }}</template>
      </el-table-column>
      <el-table-column align="center" label="资金性质" prop="purchaseAttr" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.purchaseAttr }}</template>
      </el-table-column>
      <el-table-column align="center" label="采购金额" prop="purchaseFund" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.purchaseFund }}</template>
      </el-table-column>
      <el-table-column align="center" label="单价" prop="purchasePrice" min-width="80px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.purchasePrice }}</template>
      </el-table-column>
      <el-table-column align="center" label="采购数量" prop="purchaseNum" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.purchaseNum }}</template>
      </el-table-column>
      <el-table-column align="center" label="计量单位" prop="purchaseUnit" min-width="105px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.purchaseUnit }}</template>
      </el-table-column>
      -->
      <el-table-column align="center" label="项目绩效总目标" prop="targetAll" min-width="180px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.targetAll }}</template>
      </el-table-column>
      <el-table-column align="center" label="项目绩效本年度目标" prop="targetCurrent" min-width="230px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.targetCurrent }}</template>
      </el-table-column>
      <el-table-column align="center" label="预算域同步状态" prop="ysySync" min-width="180px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <EnumTag :enum-list="getEnumList('BudgetProjectTwoSync')" :enum-key="row.ysySync" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="预算域同步结果" prop="ysySyncResult" min-width="180px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.ysySyncResult }}</template>
      </el-table-column>
      <el-table-column align="center" label="创建时间" width="180px" prop="createTime" sortable show-overflow-tooltip>
        <template v-slot="{row}"><DateTag :timestamp="row.createTime" /></template>
      </el-table-column>
      <el-table-column align="center" label="最后修改时间" width="180px" prop="updateTime" sortable show-overflow-tooltip>
        <template v-slot="{row}"><DateTag :timestamp="row.updateTime" /></template>
      </el-table-column>
      <el-table-column align="center" label="操作" width="160px" fixed="right">
        <template v-slot="{row}">
          <el-button type="primary" link @click="handleView(row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-model:total="total" v-model:page="listQuery.pageNum" v-model:limit="listQuery.pageSize" @pagination="getList" />
    <el-dialog v-model="dialogVisible" :title="dialogTypeTitle" width="70%" top="2vh">
    </el-dialog>
    <el-dialog v-model="dialogApproveVisible" title="审批流程" width="55%" top="2vh">
      <approveTimeline :businessType="approveOrderBusinessTypes().budgetProjectTwo" :businessId="obj.id" />
      <div style="text-align:right;margin: 1.875rem 0;">
        <el-button type="danger" @click="dialogApproveVisible=false">关闭</el-button>
      </div>
    </el-dialog>
    <el-dialog v-model="dialogPreviewVisible" title="查看详情" width="80%" top="2vh">
      <projectTwoDetail v-model:projectTwoId="obj.id"></projectTwoDetail>
      <div style="text-align:right;margin: 1.875rem 0;">
        <el-button type="danger" @click="dialogPreviewVisible=false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import baseConfig from '@/mixins/baseConfig'
import {doGet, doPost, doPut, doDelete, doGetDownload} from '@/config/http'
import approveTimeline from '@/views/components/base/approveTimeline.vue'
import {approveOrderBusinessTypes, customValidator, getListPageSize, notifySuccess} from "@/config/common";
import projectTwoDetail from "@/views/components/budget/projectTwoDetail";
import initListStore from '@/store/modules/initList'

const emptyObj = {
  projectOneId: null, // 一级项目ID
  code: null, // 项目编号
  name: null, // 项目名称
  viability: null, // 存续状态
  source: null, // 项目来源
  attribute: null, // 项目属性
  totalFund: null, // 申请财政总额
  putinFund: null, // 社会投入资金
  currFund: null, // 当年资金
  useGovId: null, // 用款单位ID
  applyGovId: null, // 申报单位ID
  previousArrange: null, // 上一年项目预算安排情况
  managerOrgId: null, // 主管部门ID
  managerName: null, // 主管部门联系人
  managerUserContact: null, // 主管部门联系电话
  workGovId: null, // 项目实施单位ID
  workUserId: null, // 项目负责人
  workUserContact: null, // 项目负责人联系方式
  state: null, // 状态
  libraryState: null, // 项目库状态
  startTime: null, // 起始年度
  endTime: null, // 终止年度
  summarize: null, // 项目概述
  reason: null, // 设立依据及申报理由
  isDebenture: null, // 是否债券可用项目
  isScientific: null, // 是否科研项目
  isConstruction: null, // 是否基建项目
  constructionDesc: null, // 基建立项情况
  isAgent: null, // 是否代建项目
  agentGovId: null, // 代建单位ID
  constructionApproved: null, // 发改等部门审核意见
  scientificDesc: null, // 信息化项目立项情况
  scientificType: null, // 项目建设类型
  scientificApproved: null, // 政务服务数据管理部门审核意见
  isGovernmentPurchase: null, // 是否政府采购
  purchaseProject: null, // 采购项目
  purchaseKind: null, // 采购品目
  purchaseRequire: null, // 采购需求概况
  purchaseDate: null, // 预计采购时间
  purchaseAttr: null, // 资金性质
  purchaseFund: null, // 采购金额
  purchasePrice: null, // 单价
  purchaseNum: null, // 采购数量
  purchaseUnit: null, // 计量单位
  targetAll: null, // 项目绩效总目标
  targetCurrent: null, // 项目绩效本年度目标
  ysySync: null, // 预算域同步状态
  ysySyncResult: null, // 预算域同步结果
  id: null,
  createBy: null,
  createTime: null,
  updateBy: null,
  updateTime: null,
  deleted: null,
  version: null,
}

export default {
  name: 'ProjectTwo',
  components: {
    approveTimeline,
    projectTwoDetail
  },
  mixins: [baseConfig],
  data() {
    return {
      svc: 'icims-api',
      obj: Object.assign({}, emptyObj),
      routes: [],
      dialogVisible: false,
      dialogType: 'add',
      dialogTypeTitle: '新增',
      dialogApproveVisible: false,
      checkStrictly: false,
      defaultProps: {
        children: 'children',
        label: 'title'
      },
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: false,
      dialogPreviewVisible: false,
      listQuery: {
        pageNum: 1,
        pageSize: 10,
        sortField: 'id',
        sortType: 'desc',
        projectOneId: null,
        code: null,
        name: null,
        viability: null,
        source: null,
        attribute: null,
        totalFund: null,
        putinFund: null,
        currFund: null,
        useGovId: null,
        applyGovId: null,
        previousArrange: null,
        managerOrgId: null,
        managerName: null,
        managerUserContact: null,
        workGovId: null,
        workUserId: null,
        workUserContact: null,
        state: null,
        libraryState: '3',
        startTime: null,
        endTime: null,
        isDebenture: null,
        isScientific: null,
        isConstruction: null,
        constructionDesc: null,
        isAgent: null,
        agentGovId: null,
        scientificDesc: null,
        scientificType: null,
        isGovernmentPurchase: null,
        purchaseProject: null,
        purchaseKind: null,
        purchaseRequire: null,
        purchaseDateStart: null,
        purchaseDateEnd: null,
        purchaseAttr: null,
        purchaseFund: null,
        purchasePrice: null,
        purchaseNum: null,
        purchaseUnit: null,
        ysySync: null,
        createTimeStart: null,
        createTimeEnd: null,
        updateTimeStart: null,
        updateTimeEnd: null,
      },
      selectionList: [],
      dialogFormVisible: false,
      dialogStatus: '',
      rules: {
        projectOneId: [{ required: true, validator: customValidator, min: 1, max: 20, label: '一级项目ID', trigger: ['blur', 'change'] }],
        code: [{ required: false, validator: customValidator, min: 0, max: 50, label: '项目编号', trigger: ['blur', 'change'] }],
        name: [{ required: true, validator: customValidator, min: 1, max: 100, label: '项目名称', trigger: ['blur', 'change'] }],
        viability: [{ required: false, validator: customValidator, min: 0, max: 20, label: '存续状态', trigger: ['blur', 'change'] }],
        source: [{ required: false, validator: customValidator, min: 0, max: 20, label: '项目来源', trigger: ['blur', 'change'] }],
        attribute: [{ required: false, validator: customValidator, min: 0, max: 20, label: '项目属性', trigger: ['blur', 'change'] }],
        totalFund: [{ required: false, validator: customValidator, min: 0, max: 13, label: '申请财政总额', trigger: ['blur', 'change'] }],
        putinFund: [{ required: false, validator: customValidator, min: 0, max: 13, label: '社会投入资金', trigger: ['blur', 'change'] }],
        currFund: [{ required: false, validator: customValidator, min: 0, max: 13, label: '当年资金', trigger: ['blur', 'change'] }],
        useGovId: [{ required: false, validator: customValidator, min: 0, max: 20, label: '用款单位ID', trigger: ['blur', 'change'] }],
        applyGovId: [{ required: false, validator: customValidator, min: 0, max: 20, label: '申报单位ID', trigger: ['blur', 'change'] }],
        previousArrange: [{ required: false, validator: customValidator, min: 0, max: 200, label: '上一年项目预算安排情况', trigger: ['blur', 'change'] }],
        managerOrgId: [{ required: false, validator: customValidator, min: 0, max: 20, label: '主管部门ID', trigger: ['blur', 'change'] }],
        managerName: [{ required: false, validator: customValidator, min: 0, max: 20, label: '主管部门联系人', trigger: ['blur', 'change'] }],
        managerUserContact: [{ required: false, validator: customValidator, min: 0, max: 20, label: '主管部门联系电话', trigger: ['blur', 'change'] }],
        workGovId: [{ required: false, validator: customValidator, min: 0, max: 20, label: '项目实施单位ID', trigger: ['blur', 'change'] }],
        workUserId: [{ required: false, validator: customValidator, min: 0, max: 20, label: '项目负责人', trigger: ['blur', 'change'] }],
        workUserContact: [{ required: false, validator: customValidator, min: 0, max: 20, label: '项目负责人联系方式', trigger: ['blur', 'change'] }],
        state: [{ required: false, validator: customValidator, min: 0, max: 20, label: '状态', trigger: ['blur', 'change'] }],
        startTime: [{ required: false, validator: customValidator, min: 0, max: 4, label: '起始年度', trigger: ['blur', 'change'] }],
        endTime: [{ required: false, validator: customValidator, min: 0, max: 4, label: '终止年度', trigger: ['blur', 'change'] }],
        summarize: [{ required: false, validator: customValidator, min: 0, max: 0, label: '项目概述', trigger: ['blur', 'change'] }],
        reason: [{ required: false, validator: customValidator, min: 0, max: 0, label: '设立依据及申报理由', trigger: ['blur', 'change'] }],
        isDebenture: [{ required: false, validator: customValidator, min: 0, max: 20, label: '是否债券可用项目', trigger: ['blur', 'change'] }],
        isScientific: [{ required: false, validator: customValidator, min: 0, max: 20, label: '是否科研项目', trigger: ['blur', 'change'] }],
        isConstruction: [{ required: false, validator: customValidator, min: 0, max: 20, label: '是否基建项目', trigger: ['blur', 'change'] }],
        constructionDesc: [{ required: false, validator: customValidator, min: 0, max: 20, label: '基建立项情况', trigger: ['blur', 'change'] }],
        isAgent: [{ required: false, validator: customValidator, min: 0, max: 20, label: '是否代建项目', trigger: ['blur', 'change'] }],
        agentGovId: [{ required: false, validator: customValidator, min: 0, max: 20, label: '代建单位ID', trigger: ['blur', 'change'] }],
        constructionApproved: [{ required: false, validator: customValidator, min: 0, max: 0, label: '发改等部门审核意见', trigger: ['blur', 'change'] }],
        scientificDesc: [{ required: false, validator: customValidator, min: 0, max: 200, label: '信息化项目立项情况', trigger: ['blur', 'change'] }],
        scientificType: [{ required: false, validator: customValidator, min: 0, max: 20, label: '项目建设类型', trigger: ['blur', 'change'] }],
        scientificApproved: [{ required: false, validator: customValidator, min: 0, max: 0, label: '政务服务数据管理部门审核意见', trigger: ['blur', 'change'] }],
        isGovernmentPurchase: [{ required: false, validator: customValidator, min: 0, max: 20, label: '是否政府采购', trigger: ['blur', 'change'] }],
        purchaseProject: [{ required: false, validator: customValidator, min: 0, max: 100, label: '采购项目', trigger: ['blur', 'change'] }],
        purchaseKind: [{ required: false, validator: customValidator, min: 0, max: 100, label: '采购品目', trigger: ['blur', 'change'] }],
        purchaseRequire: [{ required: false, validator: customValidator, min: 0, max: 200, label: '采购需求概况', trigger: ['blur', 'change'] }],
        purchaseDate: [{ required: false, validator: customValidator, min: 0, max: 0, label: '预计采购时间', trigger: ['blur', 'change'] }],
        purchaseAttr: [{ required: false, validator: customValidator, min: 0, max: 200, label: '资金性质', trigger: ['blur', 'change'] }],
        purchaseFund: [{ required: false, validator: customValidator, min: 0, max: 13, label: '采购金额', trigger: ['blur', 'change'] }],
        purchasePrice: [{ required: false, validator: customValidator, min: 0, max: 13, label: '单价', trigger: ['blur', 'change'] }],
        purchaseNum: [{ required: false, validator: customValidator, min: 0, max: 5, label: '采购数量', trigger: ['blur', 'change'] }],
        purchaseUnit: [{ required: false, validator: customValidator, min: 0, max: 20, label: '计量单位', trigger: ['blur', 'change'] }],
        targetAll: [{ required: false, validator: customValidator, min: 0, max: 0, label: '项目绩效总目标', trigger: ['blur', 'change'] }],
        targetCurrent: [{ required: false, validator: customValidator, min: 0, max: 0, label: '项目绩效本年度目标', trigger: ['blur', 'change'] }],
        ysySync: [{ required: false, validator: customValidator, min: 0, max: 20, label: '预算域同步状态', trigger: ['blur', 'change'] }],
        ysySyncResult: [{ required: false, validator: customValidator, min: 0, max: 0, label: '预算域同步结果', trigger: ['blur', 'change'] }],
      },
      organizationList: initListStore().organizationList,
      governmentList: initListStore().governmentList,
      userList: initListStore().userList,
      budgetCompetentList: initListStore().budgetCompetentList,
    }
  },
  computed: {
    routesData() {
      return this.routes
    },
  },
  created() {
    this.getList()
    // this.initList()
  },
  methods: {
    approveOrderBusinessTypes,
    // async initList() {
    //   let p1 = doGet(this.svc, '/organization/page', {pageSize: getListPageSize()}, false)
    //   let p2 = doGet(this.svc, '/government/page', {pageSize: getListPageSize()}, false)
    //   let p3 = doGet(this.svc, '/user/page', {pageSize: getListPageSize()}, false)
    //   let p4 = doGet(this.svc, '/budget-competent/page', {pageSize: getListPageSize()}, false)
    //   let resArray = await Promise.all([p1, p2, p3, p4])
    //   this.organizationList = resArray[0]['records']
    //   this.governmentList = resArray[1]['records']
    //   this.userList = resArray[2]['records']
    //   this.budgetCompetentList = resArray[3]['records']
    // },
    getList() {
      this.listLoading = true
      doGet(this.svc, '/budget-project-two/page', this.listQuery).then(res => {
        this.listLoading = false
        this.list = res['records']
        this.total = parseInt(res['total'])
      }).catch(e => {
        console.error(e)
        this.listLoading = false
      })
    },
    handleResetQuery() {
      this.resetForm("listQuery")
      this.listQuery.purchaseDateStart = ''
      this.listQuery.purchaseDateEnd = ''
    },
    handleFilter() {
      this.listQuery.pageNum = 1
      this.getList()
    },
    handleModifyStatus(row, status) {
      this.$message({
        message: '操作Success',
        type: 'success'
      })
      row.status = status
    },
    handleSelectionChange(data) {
      this.selectionList = data
    },
    handleSortChange(data) {
      const { prop, order } = data
      this.listQuery.sortField = prop
      this.listQuery.sortType = order === 'ascending' ? 'asc' : 'desc'
      this.handleFilter()
    },
    handleEdit(row) {
      this.goTargetByName('projectTwoEdit', {id: row.id, oper: 'edit'})
    },
    handleView(row) {
      this.dialogPreviewVisible = true
      this.obj = Object.assign({}, row)
    },
    handleAdd() {
      this.goTargetByName('projectTwoEdit', {oper: 'add'})
    },
    handleExport() {
      doGetDownload(this.svc, '/budget-project-two/export', this.listQuery)
    },
    handleDelete(row) {
      this.$confirm('您确定删除么？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(_ => {
        doDelete(this.svc, '/budget-project-two/' + row.id, {}).then(() => {
          notifySuccess('操作成功')
          this.getList()
          this.dialogVisible = false
        })
      })
    },
    handleApprove(row) {
      this.obj = Object.assign({}, row)
      this.dialogApproveVisible = true
    },
    handleRevocation(row) {
      this.$confirm('您确定撤回么？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(_ => {
        doPost(this.svc, `/customBudgetProject/revocationBudgetProjectTwo/${row.id}`, {}).then(() => {
          notifySuccess('操作成功')
          this.getList()
        })
      })
    },
    handleSync(row) {
      this.$confirm('您确定要同步到预算域么？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(_ => {
        doPost(this.svc, `/customBudgetProject/syncBudgetProjectTwo/${row.id}`, {}).then(() => {
          notifySuccess('操作成功')
          this.getList()
        })
      })
    },
  }
}
</script>
